<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>吃什么</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <% include include/head.ejs %>
        <script>
            function randomObj(){
                var groupId = $("#picker").attr('data-values');
                if(!groupId){
                    $.alert("请先选择爱好组");
                    return;
                }
                $.ajax({
                    url:'/random/getItem',
                    data:{groupId:groupId},
                    success:function(data){
                       $.alert(data.itemName,'');
                    }
                });
            }
        </script>
    </head>
    <body>
        <% include include/nav.ejs %>
        <div class="container">
            <div class="weui-cells">
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" placeholder="请选择爱好组" id="picker">
                    </div>
                </div>
            </div>
            <button type="button" class="btn btn-primary btn-lg btn-block" onclick="randomObj()">随机</button>
        </div>
        <% include include/head-js.ejs %>
        <script>
            $("#picker").select({
                title: "选择随机组",
                items: [
                    <% for(var i=0;i<groupList.length; i++){ %>
                        { 
                            title:'<%=groupList[i].groupName%>',
                            value:'<%=groupList[i].groupId%>'
                        },
                    <% } %>
                ]
            });
        </script>
    </body>
</html>